package com.novunda.platform.repositories;

import com.novunda.platform.common.repositories.BaseRepository;
import com.novunda.platform.entities.Dict;
import com.novunda.platform.entities.base.BaseEntity;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

/**
 * @author linfeng
 */
public interface DictRepository extends BaseRepository<Dict, Long> {

    @Modifying
    @Query("update Dict set delFlag='" + BaseEntity.DEL_FLAG_DELETE + "' where id = ?1")
    int deleteById(Long id);

    @Query("from Dict where delFlag='" + BaseEntity.DEL_FLAG_NORMAL + "' order by sort")
    List<Dict> findAllList();

    @Query("select type from Dict where delFlag='" + BaseEntity.DEL_FLAG_NORMAL + "' group by type")
    List<String> findTypeList();

}
